import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// 全局样式
import './assets/css/global.css'
// 导入字体图标
import './assets/fonts/iconfont.css'
// 网格布局
import ZkTable from 'vue-table-with-tree-grid'
// 导入axios
import axios from 'axios'
import VueQuillEditor from 'vue-quill-editor'

// require styles
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

Vue.use(VueQuillEditor)
Vue.component('tree-gird', ZkTable)
// 默认的url路径
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
// axios请求拦截：
axios.interceptors.request.use(config => {
  // 给请求头挂载Authorization属性
  if (config.url !== '/login') {
    config.headers.Authorization = window.sessionStorage.getItem('token')
  }
  return config
})
// 挂载到vue原型上，通过this可以访问axios
Vue.prototype.$axios = axios

Vue.config.productionTip = false
Vue.filter('dateFormat', (date) => {
  const obj = new Date(date * 1000)
  const y = obj.getFullYear()
  const M = (obj.getMonth() + 1).toString().padStart(2, 0)
  const d = obj.getDate().toString().padStart(2, 0)
  return `${y}-${M}-${d}`
})
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
